package cn.hicard.risk.dao.limit.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.hicard.risk.dao.BaseDao;
import cn.hicard.risk.entity.BdMerchinfo;


@Repository
public class LimitMerchDaoImpl extends BaseDao<BdMerchinfo>  {

	
	public List<BdMerchinfo> findLimitMerch()throws Exception {
		
		String hql = "FROM BdMerchinfo WHERE (dayliquidation<>NULL AND dayliquidation <>'') OR (dayclearinglimits<>NULL AND dayclearinglimits<>'') ";
		List<BdMerchinfo> list = super.findByHql(hql);
		return list;
	}
	
	/**
	 * 查询需要调单的商户列表
	 */
	public List<BdMerchinfo> findCallList(BdMerchinfo merch) throws Exception {
		String hql = "FROM BdMerchinfo WHERE 1=1 AND getTicket=? ";
		// 交易是否调单
		String iswatch = merch.getGetTicket();
		return super.findByHql(hql, iswatch);
	}
	
	/**
	 * 查询清算周期为T+2的商户号列表
	 */
/*	public List<String> findPeriodList(BdMerchinfo merch) throws Exception {
		String hql = "SELECT merNo FROM BdMerchinfo WHERE 1=1 AND period=?";
		String period = merch.getPeriod();
		return super.findFieldByHql(hql,period);
	}*/
	
	
	public BdMerchinfo getOne(BdMerchinfo merch) throws Exception {
	
		BdMerchinfo result = null;

		// 使用应该是唯一的[汇卡商户号]查询	
		List<BdMerchinfo> list = super.findByHql("FROM BdMerchinfo WHERE hmId=?", merch.getHmId());
		  if(list !=null && list.size() > 0){
			result = list.get(0);
		 }

		return result;
	}
	
}
